﻿using System;
using System.Collections;

public class BattleLogicRunner
{
    public BattleLogicRunner()
    {
    }

    public void Start() 
    {
        // setup party
        m_playerParty.TurnManager().SetTurnFactor(1.0f);
        {
            Character hero = new Character();
            hero.Name = "hero1";
            //hero.m_attackPower;
            //hero.m_currentHealth;
            //hero.m_maxHealth;
            m_playerParty.Add(hero);
        }
        {
            Character hero = new Character();
            hero.Name = "hero2";
            //hero.m_attackPower;
            //hero.m_currentHealth;
            //hero.m_maxHealth;
            m_playerParty.Add(hero);
        }
        {
            Character hero = new Character();
            hero.Name = "hero3";
            //hero.m_attackPower;
            //hero.m_currentHealth;
            //hero.m_maxHealth;
            m_playerParty.Add(hero);
        }
        {
            Character hero = new Character();
            hero.Name = "hero4";
            //hero.m_attackPower;
            //hero.m_currentHealth;
            //hero.m_maxHealth;
            m_playerParty.Add(hero);
        }
        // setup monster 
        m_mobGroup.TurnManager().SetTurnFactor(0.5f);
    }

    public void Update()
    {
        double deltaTime = util.DeltaTime();

        m_playerParty.Update(deltaTime);
        m_mobGroup.Update(deltaTime);

        // and input check
        if (m_playerParty.TurnManager().HaveTurn())
        {
            Character hero = m_playerParty.Select();
            Monster mob = m_mobGroup.SelectTarget(); // random or any 
            hero.Attack(mob);
        }

        if (m_mobGroup.TurnManager().HaveTurn())
        {
            Monster mob = m_mobGroup.Select();
            Character hero = m_playerParty.SelectTarget();
            mob.Attack(hero);
        }

    }

    private PlayerParty m_playerParty = new PlayerParty();
    private MonsterGroup m_mobGroup = new MonsterGroup();
    private JoyUtil util = new JoyUtil(); // for time, random
}